package com.application.lucky.request;

import com.application.lucky.bean.jsonBean.BaoBiaoBean;
import com.application.lucky.bean.jsonBean.ChaZhangBean;
import com.application.lucky.bean.jsonBean.GroupListbean;
import com.application.lucky.bean.jsonBean.GroupUserLIstbean;
import com.application.lucky.bean.jsonBean.HistoryBean;
import com.application.lucky.bean.jsonBean.MoneyHistoryBean;
import com.application.lucky.bean.jsonBean.PeiLvBean;
import com.application.lucky.bean.jsonBean.RecharTypeBean;
import com.application.lucky.bean.jsonBean.RechargeItem;
import com.application.lucky.bean.jsonBean.RedPListbean;
import com.application.lucky.bean.jsonBean.RoomInfoBean;
import com.application.lucky.bean.jsonBean.WebMessageBean;
import com.application.lucky.bean.sqliteBean.BankBean;
import com.application.lucky.manager.UserManagers;
import com.application.lucky.request.nav.UrlList;
import com.application.lucky.request.nav.UrlManager;
import com.qunar.im.ui.util.MoneyUtils;
import com.baselib.libnetwork.net.libnetworkcomponent.BaseResponse;
import com.baselib.libnetwork.net.libnetworkcomponent.PieBaseRequest;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RedPRequest extends PieBaseRequest {
    public void red_room_type_list(CallBackEx<BaseResponse<List<GroupListbean>>> callBackEx) {
        String url = UrlManager.getUrl(UrlList.red_room_type_list);
        get(url, callBackEx);
    }

    public void red_send(String room_id, String red_money, String red_num, String x_no, String pass, CallBackEx<BaseResponse<RedPListbean>> backEx) {
        Map<String, String> param = new HashMap();
        param.put("room_id", room_id);
        param.put("red_money", red_money);
        param.put("red_num", red_num);
        param.put("x_no", x_no);
        param.put("password", pass);
        String url = UrlManager.getUrl(UrlList.red_send);
        post(url, param, backEx);
    }

    public void red_info(String id, CallBackEx<BaseResponse<RedPListbean>> callBackEx) {
        String url = UrlManager.getUrl(UrlList.red_info);
        get(url, "red_id", id, callBackEx);
    }

    public void red_room_user_list(String id, CallBackEx<BaseResponse<List<GroupUserLIstbean>>> baseResponseCallBackEx) {

        String url = UrlManager.getUrl(UrlList.red_room_user_list);
        get(url, "room_id", id, baseResponseCallBackEx);
    }

    public void red_join_room(String id, CallBackEx<BaseResponse<RoomInfoBean>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_join_room);
        Map<String, String> param = new HashMap<>();
        param.put("nick_name", UserManagers.getInstance().getUserName());
        param.put("head_pic", UserManagers.getInstance().getPic());
        param.put("room_type_id", id);
        get(url, param, baseResponseCallBackEx);
    }

    public void red_balance(CallBackEx<BaseResponse<Integer>> backEx) {
        String url = UrlManager.getUrl(UrlList.red_balance);
        get(url, backEx);
    }

    public void red_multiple_list(CallBackEx<BaseResponse<List<PeiLvBean>>> back) {
        String url = UrlManager.getUrl(UrlList.red_multiple_list);
        get(url, back);
    }

    public void red_history(int index, CallBackEx<BaseResponse<HistoryBean>> backEx) {
        String url = UrlManager.getUrl(UrlList.red_history);
        Map<String, String> param = new HashMap<>();
        param.put("index", index + "");
        param.put("length", 10 + "");
        param.put("nick_name", UserManagers.getInstance().getUserName());
        param.put("head_pic", UserManagers.getInstance().getPic());
        get(url, param, backEx);
    }

    public void red_room_history(int index, String roomID, CallBackEx<BaseResponse<HistoryBean>> backEx) {
        String url = UrlManager.getUrl(UrlList.red_room_history);
        Map<String, String> param = new HashMap<>();
        param.put("index", index + "");
        param.put("room_id", roomID);
        param.put("length", 10 + "");
        param.put("nick_name", UserManagers.getInstance().getUserName());
        param.put("head_pic", UserManagers.getInstance().getPic());
        get(url, param, backEx);
    }

    public void red_user_balance_history(int index, int length, int type, CallBackEx<BaseResponse<MoneyHistoryBean>> back) {
        String url = UrlManager.getUrl(UrlList.red_user_balance_history);
        Map<String, String> param = new HashMap<>();
        param.put("index", index + "");
        param.put("change_type", type + "");
        param.put("length", length + "");
        get(url, param, back);
    }

    public void red_transfer(Integer money, String id, CallBackEx<BaseResponse<String>> back) {
//        balance user_id

        String url = UrlManager.getUrl(UrlList.red_transfer);
        Map<String, String> param = new HashMap<>();
        param.put("balance", MoneyUtils.getServerMoney(money));
        param.put("user_id", id);
        post(url, param, back);
    }

    public void tixian(int money, BankBean bankBean, CallBackEx<BaseResponse<String>> backEx) {

        String url = UrlManager.getUrl(UrlList.red_took_balance);
        Map<String, String> param = new HashMap<>();
        param.put("balance", MoneyUtils.getServerMoney(money));
        param.put("bank", bankBean.num);
        param.put("name", bankBean.name);
        param.put("bank_name", bankBean.accountNamw + "");
        param.put("bank_address", bankBean.getAccountAddress() + "");

        post(url, param, backEx);
    }

    public void red_receive(String transferId, CallBackEx<BaseResponse<String>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_receive);
        post(url, "transfer_no", transferId, baseResponseCallBackEx);
    }

    public void red_recharge_info(CallBackEx<BaseResponse<RecharTypeBean>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_recharge_info);
        get(url, baseResponseCallBackEx);
    }

    public void red_password(CallBackEx<BaseResponse<String>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_password);
        get(url, baseResponseCallBackEx);
    }

    public void red_password_update(String pas, String pasold, CallBackEx<BaseResponse<String>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_password_update);
        Map<String, String> param = new HashMap<>();
        param.put("password", pas);
        if (pasold == null) {
            param.put("old_password", "");
        } else {
            param.put("old_password", pasold);
        }

        post(url, param, baseResponseCallBackEx);
    }

    public void sendMessage(WebMessageBean bean) {
        String url = UrlManager.getUrl("ws_send");
        Map<String, String> param = new HashMap<>();
        param.put("from", bean.from);
        param.put("groupId", bean.groupId);
        param.put("messageType", bean.messageType);
        param.put("message", bean.message);
        post(url, param, null);
    }

    public void red_recharge_submit(String recharge, String channel, CallBackEx<BaseResponse> callback) {
        String url = UrlManager.getUrl(UrlList.red_recharge_submit);
        Map<String, String> param = new HashMap<>();
        param.put("recharge", recharge); // 金额
        param.put("channel", channel);
        post(url, param, callback);
    }

    public void red_accounts_overview(long time, long endTime, CallBackEx<BaseResponse<BaoBiaoBean>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_accounts_overview);
        Map<String, String> param = new HashMap<>();
        param.put("startTime", time + "");
        param.put("endTime", endTime + "");
        get(url, param, baseResponseCallBackEx);
    }

    public void red_accounts_check(String id,CallBackEx<BaseResponse<ChaZhangBean>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.red_accounts_check);
        Map<String, String> param = new HashMap<>();
        param.put("room_id", id + "");
        get(url, param,baseResponseCallBackEx);
    }

    public void red_recharge_channel(CallBackEx<BaseResponse<List<RechargeItem>>> callBackEx) {
        String url = UrlManager.getUrl(UrlList.red_recharge_channel);
        get(url, callBackEx);
    }

    public void relation_group_join(String roomId, CallBackEx<BaseResponse<String>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.relation_group_join);
        post(url, "groupId", roomId, baseResponseCallBackEx);
    }

    public void relation_group_exit(String roomId, CallBackEx<BaseResponse<String>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.relation_group_exit);
        post(url, "groupId", roomId, baseResponseCallBackEx);
    }

    public void relation_group_list(String id, CallBackEx<BaseResponse<List<GroupUserLIstbean>>> baseResponseCallBackEx) {
        String url = UrlManager.getUrl(UrlList.relation_group_list);
        get(url, "groupId", id, baseResponseCallBackEx);
    }
}
